<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="http://eureka.yigolden.net/stringutils/sutaglib/1.0" prefix="su"%>
<c:set var="denialReason" value="0" />
<c:choose>
  <c:when test="${bookitem.owner.UID eq user.UID }">
    <c:set var="denialReason" value="1" />
  </c:when>
</c:choose>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8" />
<title>确认购买</title>

		<!-- Attach our CSS -->
	  	<link type="text/css" href="${staticResources}/css/confirmpurchase.css" rel="stylesheet" />	
	  	<script type="text/javascript" src="${staticResources}/js/ajax.js"></script>
	  	
		<!-- Attach necessary scripts -->
		<script type="text/javascript" src="${staticResources}/js/jquery-1.4.4.min.js"></script>
		<!-- <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.min.js"></script> -->
		<script type="text/javascript" src="${staticResources}/js/jquery.reveal.js"></script>
		
		<style type="text/css">
			body { font-family: "HelveticaNeue","Helvetica-Neue", "Helvetica", "Arial", sans-serif; }
			.big-link { }
			
			.name{ font-size:20px;  width:300px; height:30px;}
			.name b{ font-size:22px; color:#0000CC; }
		</style>

<script type="text/javascript">

function refreshcaptcha()
{
	var timenow = new Date().getTime();    
	var captcha = document.getElementById("imgverifycode").src = "${contextPath}/captcha?flag=cfpc&random="+timenow;
}

function confirmPurchase()
{
	var beid = document.getElementById("beid").value;
	var verifycode = document.getElementById("verifycode").value;
	var redirect_url = document.getElementById("redirect_url").value;
	var mode = "ajax";
	
	var params="beid=" + encodeURIComponent(beid);
	params+="&verifycode="+encodeURIComponent(verifycode);
	params+="&redirect_url="+encodeURIComponent(redirect_url);
	params+="&mode="+encodeURIComponent(mode);
	
	if(!document.getElementById("checkbox").checked)
	{
		document.getElementById("error").innerHTML = "是否同意相关文件";
		return;
	}
	
	doAjax("StartTransaction"
			,params,function(rst){
	var rst=eval('(' +rst+ ')');
	if (rst.status == 0) {
		parent.location.href = rst.redirectURL;
	} else {
		document.getElementById("error").innerHTML = rst.message;
	}
	});
}

</script>
</head>

<body>

<form name="StartTransaction" action="StartTransaction" method="post" onsubmit="confirmPurchase();return false;">
		
     <div class="main2" style="margin: -15px 20px -10px -50px;">
	      
	           <div class="lmain2" style="margin: 15px -20px 0px 55px;"><img src="${contextPath}/Books/GetBookPicture?beid=${bookitem.beID}&size=min" style="max-width:180px; max-height:220px;" alt=""></div>
		       <div class="rmain2" style="margin: 15px 60px 0px -60px;">
		           
			         <div class="book"> 
			             <div class="name">书名：<b>${fn:escapeXml(bookitem.name)}</b></div>
			             <small>版本：${fn:escapeXml(bookitem.version)}</small><br>
			             <small>出版社：${fn:escapeXml(bookitem.publisher)}</small><br>
			             <small>主编：${fn:escapeXml(bookitem.chiefEditor)}</small><br>
			             <small>分类：${fn:escapeXml(bookitem.category.name)}</small><br>
			             <div class="price">价格：<b>￥${fn:escapeXml(bookitem.price)}</b></div>
			         </div>
			         
			         <c:choose>
			           <c:when test="${denialReason eq 1 }">
			           <div class="yam">
			             <span style="color:red;">您不能购买自己发布的书籍！</span>
			           </div>
			           </c:when>
			           <c:otherwise>
			            <div class="yzm" style="margin: -30px 0px 0px 10px;">
			            验证码：<input type="text" id="verifycode" style="width:60px; height:20px;margin: -5px 0px 0px 0px;"/><img id="imgverifycode" src="${contextPath}/captcha?flag=cfpc" width="80" height="30" style="margin: 20px 0px 0px 0px; pading-top:20px;" alt=""><a href="javascipt:void(0)" onclick = "refreshcaptcha();return false;">换一张</a>
			            </div>
			           </c:otherwise>
			         </c:choose>
					 </div>
			   </div>
		  		     
	  <c:if test="${denialReason eq 0 }">
	  <div class="botton2" style="margin: 20px 0px 0px 15px;">
	       <div class="gm">
	            
	                   <input type="image" style=""src="${staticResources}/image/confirmpurchase_11.gif" width="150" height="45" alt="" class="button" name="commit" value=""/>
	            
	       </div>
	       <div class="error" id="error"></div>
		   
	  </div>
	  <div class="det">
				<label> <input type="checkbox" name="checkbox" id="checkbox" />我已阅读并同意<a href="">相关文件</a></label>				
	  </div>
	  </c:if>

	  <input type="hidden" name="beid" id="beid" value="${bookitem.beID}" />
	  <input type="hidden" name="redirect_url" id="redirect_url" value="${su:encodeLink(param.redirect_url) }" />
</form>



</body>
</html>